<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./static/axios.min.js"></script>
    <script src="./static/vue.min.js"></script>
    <!-- 本地引入lib-master -->
    <link rel="stylesheet" type="text/css" href="lib-master/theme-chalk/index.css" />
    <script src="lib-master/index.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
    <template>
    <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
                    <el-form-item label="商品id" prop="goodsId">
      <el-input v-model="dataForm.goodsId" placeholder="商品id"></el-input>
    </el-form-item>
                <el-form-item label="用户id" prop="userId">
      <el-input v-model="dataForm.userId" placeholder="用户id"></el-input>
    </el-form-item>
                <el-form-item label="拼团状态(0.开启,1关闭,2.失效,3.完成)" prop="tourDivStatus">
      <el-input v-model="dataForm.tourDivStatus" placeholder="拼团状态(0.开启,1关闭,2.失效,3.完成)"></el-input>
    </el-form-item>
                <el-form-item label="开始时间" prop="startTime">
      <el-input v-model="dataForm.startTime" placeholder="开始时间"></el-input>
    </el-form-item>
                <el-form-item label="结束时间" prop="endTime">
      <el-input v-model="dataForm.endTime" placeholder="结束时间"></el-input>
    </el-form-item>
                <el-form-item label="参团人数" prop="joinNum">
      <el-input v-model="dataForm.joinNum" placeholder="参团人数"></el-input>
    </el-form-item>
                <el-form-item label="成团人数" prop="orderClusteringCount">
      <el-input v-model="dataForm.orderClusteringCount" placeholder="成团人数"></el-input>
    </el-form-item>
                <el-form-item label="成团最少人数" prop="orderLeastClusteringCount">
      <el-input v-model="dataForm.orderLeastClusteringCount" placeholder="成团最少人数"></el-input>
    </el-form-item>
                <el-form-item label="商品原价" prop="goodsPrice">
      <el-input v-model="dataForm.goodsPrice" placeholder="商品原价"></el-input>
    </el-form-item>
                <el-form-item label="开团价格" prop="headPrice">
      <el-input v-model="dataForm.headPrice" placeholder="开团价格"></el-input>
    </el-form-item>
                <el-form-item label="支付金额" prop="payPrice">
      <el-input v-model="dataForm.payPrice" placeholder="支付金额"></el-input>
    </el-form-item>
                <el-form-item label="支付时间" prop="payTime">
      <el-input v-model="dataForm.payTime" placeholder="支付时间"></el-input>
    </el-form-item>
                <el-form-item label="订单总额" prop="totalAmount">
      <el-input v-model="dataForm.totalAmount" placeholder="订单总额"></el-input>
    </el-form-item>
                <el-form-item label="应付总额" prop="payAmount">
      <el-input v-model="dataForm.payAmount" placeholder="应付总额"></el-input>
    </el-form-item>
                <el-form-item label="支付状态(0.支付成功,1.支付失败)" prop="payState">
      <el-input v-model="dataForm.payState" placeholder="支付状态(0.支付成功,1.支付失败)"></el-input>
    </el-form-item>
            </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
    </el-dialog>
    </template>
</div>
</body>
<script>
    new Vue({
        el: "#app",
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          goodsId: '',
          userId: '',
          tourDivStatus: '',
          startTime: '',
          endTime: '',
          joinNum: '',
          orderClusteringCount: '',
          orderLeastClusteringCount: '',
          goodsPrice: '',
          headPrice: '',
          payPrice: '',
          payTime: '',
          totalAmount: '',
          payAmount: '',
          payState: ''
        },
        dataRule: {
          goodsId: [
            { required: true, message: '商品id不能为空', trigger: 'blur' }
          ],
          userId: [
            { required: true, message: '用户id不能为空', trigger: 'blur' }
          ],
          tourDivStatus: [
            { required: true, message: '拼团状态(0.开启,1关闭,2.失效,3.完成)不能为空', trigger: 'blur' }
          ],
          startTime: [
            { required: true, message: '开始时间不能为空', trigger: 'blur' }
          ],
          endTime: [
            { required: true, message: '结束时间不能为空', trigger: 'blur' }
          ],
          joinNum: [
            { required: true, message: '参团人数不能为空', trigger: 'blur' }
          ],
          orderClusteringCount: [
            { required: true, message: '成团人数不能为空', trigger: 'blur' }
          ],
          orderLeastClusteringCount: [
            { required: true, message: '成团最少人数不能为空', trigger: 'blur' }
          ],
          goodsPrice: [
            { required: true, message: '商品原价不能为空', trigger: 'blur' }
          ],
          headPrice: [
            { required: true, message: '开团价格不能为空', trigger: 'blur' }
          ],
          payPrice: [
            { required: true, message: '支付金额不能为空', trigger: 'blur' }
          ],
          payTime: [
            { required: true, message: '支付时间不能为空', trigger: 'blur' }
          ],
          totalAmount: [
            { required: true, message: '订单总额不能为空', trigger: 'blur' }
          ],
          payAmount: [
            { required: true, message: '应付总额不能为空', trigger: 'blur' }
          ],
          payState: [
            { required: true, message: '支付状态(0.支付成功,1.支付失败)不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            if (this.dataForm.id == "") {
                axios.post("http://localhost:7000/tourdiv/tourdivorder/save", this.dataForm).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.getDataList();
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
            }else {
                axios.post("http://localhost:7000/tourdiv/tourdivorder/update", this.dataForm).then(
                        ({
                             data
                         }) => {
                            if (data && data.code === 0) {
                                this.$message({
                                    message: '操作成功',
                                    type: 'success',
                                    duration: 1500,
                                    onClose: () => {
                                        this.visible = false
                                        this.getDataList();
                                    }
                                })
                            } else {
                                this.$message.error(data.msg)
                            }
                        })
            }
          }
        })
      }
    }
  })
</script>
</html>
